#include <iostream>
#include <fstream>
#include <cstdlib>
#include <ctime>

using namespace std;

int main(int argc, char * argv[])
{
    if (argc < 3)
    {
        cout << "Insufficient number of arguments. Please, start ";
        cout << "this program like >arrayGenerator array_size where_to_save" << endl;
        exit(1);
    }
    srand(time(NULL));
    int cnt = atoi(argv[1]);
    ofstream arrFile;
    arrFile.open(argv[2]);
    arrFile << cnt << endl;
    int num;
    cout << "Generating " << cnt << " numbers into file " << argv[2] << "..." << endl;
    for (int i = 0; i < cnt; i++)
    {
	num = rand() + 1;
//        num = rand();
//        cout << num << " ";
        arrFile << num << " ";
    }
    arrFile << endl;
    arrFile.close();
    cout << "\nFinished" << endl;

    return 0;
}
